package com.lq.educationsystem.teacher.controller;

import com.lq.educationsystem.common.entiy.ClassesTb;
import com.lq.educationsystem.common.util.Result;
import com.lq.educationsystem.common.util.ResultBuild;
import com.lq.educationsystem.common.util.ResultPage;
import com.lq.educationsystem.common.vo.*;
import com.lq.educationsystem.teacher.entiy.TeacherTb;
import com.lq.educationsystem.teacher.service.TeacherBaseService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "教师管理基础的接口")
@RequestMapping("/teacher/base")
@RestController
public class TeacherBaseController {

    //导入service
    @Autowired
    TeacherBaseService teacherBaseService;
    //通过id查询
    @Operation(summary ="通过教师id查询信息")
    @PostMapping("/querybyid")
    public Result<TeacherTb> queryTeacherById(@RequestBody TeacherTb teacherTb){
        Integer teacherId = teacherTb.getTeacherId();
        //Service

        Result result= teacherBaseService.queryById(teacherId);

        return result;
    }
    //数据插入
    @Operation(summary ="插入教师信息")
    @PostMapping("/insert")
    public Result insertTeacherInfo(@RequestBody TeacherTb teacherTb){

        //新增用户

        teacherBaseService.insertTeacherInfo(teacherTb);

        return ResultBuild.buildOk();
    }
    //数据更新
    @Operation(summary = "更新教师数据")
    @PostMapping("/update")
    public Result updateStudentInfo(@RequestBody TeacherTb teacherTb){

        //新增用户

        teacherBaseService.updateTeacherInfo(teacherTb);

        return ResultBuild.buildOk();
    }
    //数据删除
    @Operation(summary = "/通过教师id删除教师数据")
    @PostMapping("/delete")
    public Result deleteStudentInfo(@RequestBody TeacherTb teacherTb){

        Integer teacherId = teacherTb.getTeacherId();
        //删除用户

        teacherBaseService.deleteTeacherInfo(teacherId);

        return ResultBuild.buildOk();
    }

    @Operation(summary = "分页查询数据")
    @PostMapping("/query")
    public ResultPage<TeacherTb> queryList(@RequestBody TeacherPageVo teacherInfo){

        //数据插入
        ResultPage<TeacherTb>  teacherTbResultPage =teacherBaseService.queryList(teacherInfo);
        return teacherTbResultPage;
    }
    /**
     * 通过教师id批量查询数据
     */
    @Operation(summary = "通过教师id批量查询教师数据")
    @PostMapping("/query/batch/teacher")
    public ResultPage<TeacherTb> queryBatchTeacherInfoByTeacherIdList(@RequestBody List<Integer> teacherIdListInfo){
        ResultPage<TeacherTb> teacherTbResultPage = teacherBaseService.queryBatchTeacherInfoByTeacherIdList(teacherIdListInfo);
        return teacherTbResultPage;
    }

    /**
     * 通过教师id查询教师所授班级内学生的信息
     * @param
     * @return
     */
    @Operation(summary = "通过教师id查询教师所授班级内学生的信息")
    @PostMapping("/query/teacher/student")
    public ResultPage<SubjectClassesStudentVo> querySubjectClassesStudentInfoByTeacherId(@RequestBody ClassesPageVo classesPageInfo) {
        //接受参数返回后端
        ResultPage<SubjectClassesStudentVo> subjectClassesStudentVoResultPage= teacherBaseService.querySubjectClassesStudentInfoByTeacherId(classesPageInfo);

        return subjectClassesStudentVoResultPage;
    }

    @Operation(summary = "通过教师id查询教师所授课程")
    @PostMapping("/query/teacher/subject")
    public ResultPage<TeacherSubjectClassesVo> queryTeacherSubjectInfoByTeacherId(@RequestBody TeacherPageVo teacherPageVo) {
        ResultPage<TeacherSubjectClassesVo> teacherSubjectVoResultPage = teacherBaseService.queryTeacherSubjectInfoByTeacherId(teacherPageVo);
        return teacherSubjectVoResultPage;
    }
    /**
     * 通过教师id查询教师所授班级内学生的分数
     * @param classesStudentSubjectScorePageVo
     * @return
     */
    @Operation(summary = "通过教师id查询教师所授班级内学生的分数")
    @PostMapping("/query/teacher/student/score")
    public ResultPage<SubjectClassesStudentScoreVo> querySubjectClassesStudentScoreByTeacherId(@RequestBody ClassesStudentSubjectScorePageVo classesStudentSubjectScorePageVo) {


        ResultPage<SubjectClassesStudentScoreVo> querySubjectClassesStudentScoreByTeacherIdResult = teacherBaseService.querySubjectClassesStudentScoreByTeacherId(classesStudentSubjectScorePageVo);
        return querySubjectClassesStudentScoreByTeacherIdResult;
    }

    /**
     * 发布课程考试 这里传递的参数没有确定
     */
    @Operation(summary = "考试发布")
    @PostMapping("/release/subject/examination")
    public Result teacherReleaseSubjectExaminationInfo(@RequestBody TeacherSubjectExaminationVo teacherSubjectExaminationInfo) {

        Result result = teacherBaseService.teacherReleaseSubjectExaminationInfo(teacherSubjectExaminationInfo);

        return result;

    }

    //教师数据修改
    @Operation(summary = "教师数据修改")
    @PostMapping("/update/student/score")
    public Result teacherUpdateStudentScoreBySubjectIdAndStudentId(@RequestBody SubjectStudentScoreVo subjectStudentScoreVo) {
        Result result= teacherBaseService.teacherUpdateStudentScoreBySubjectIdAndStudentId(subjectStudentScoreVo);
        return result;
    }



}

